package Java1Test.ArrayList;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class ArrayListTest4 {
    public static void main(String[] args) {
        ArrayList<User> list = new ArrayList<>();
        User u1 = new User(1, "zhangsan", "123");
        User u2 = new User(2, "lisi", "1234");
        User u3 = new User(3, "wangwu", "12345");
        list.add(u1);
        list.add(u2);
        list.add(u3);
        System.out.println(getInfoById(list, 0));

    }

    public static boolean getInfoById(ArrayList<User> list, int id) {
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getId() == id) {
                return true;
            }
        }
        return false;
    }
}
